<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-- | Constructed Product Result analysis. Identifies functions that surely</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- return heap-allocated records on every code path, so that we can eliminate</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- said heap allocation by performing a worker/wrapper split.</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- See https://www.microsoft.com/en-us/research/publication/constructed-product-result-analysis-haskell/.</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- CPR analysis should happen after strictness analysis.</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- See Note [Phase ordering].</span><span>
</span><span id="line-10"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.CprAnal</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalProgram"><span class="hs-identifier">cprAnalProgram</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-14"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-15"></span><span>
</span><span id="line-16"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html"><span class="hs-identifier">GHC.Types.Demand</span></a></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html"><span class="hs-identifier">GHC.Types.Cpr</span></a></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Seq.html"><span class="hs-identifier">GHC.Core.Seq</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier">runRWKey</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier">exprIsHNF</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#dumpIdInfoOfProgram"><span class="hs-identifier">dumpIdInfoOfProgram</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html"><span class="hs-identifier">GHC.Core.FamInstEnv</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.WorkWrap.Utils.html"><span class="hs-identifier">GHC.Core.Opt.WorkWrap.Utils</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#dumpIfSet_dyn"><span class="hs-identifier">dumpIfSet_dyn</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#DumpFormat"><span class="hs-identifier">DumpFormat</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier">isJust</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#isNothing"><span class="hs-identifier">isNothing</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier">guard</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-comment">{- Note [Constructed Product Result]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The goal of Constructed Product Result analysis is to identify functions that
surely return heap-allocated records on every code path, so that we can
eliminate said heap allocation by performing a worker/wrapper split.

@swap@ below is such a function:

  swap (a, b) = (b, a)

A @case@ on an application of @swap@, like
@case swap (10, 42) of (a, b) -&gt; a + b@ could cancel away
(by case-of-known-constructor) if we &quot;inlined&quot; @swap@ and simplified. We then
say that @swap@ has the CPR property.

We can't inline recursive functions, but similar reasoning applies there:

  f x n = case n of
    0 -&gt; (x, 0)
    _ -&gt; f (x+1) (n-1)

Inductively, @case f 1 2 of (a, b) -&gt; a + b@ could cancel away the constructed
product with the case. So @f@, too, has the CPR property. But we can't really
&quot;inline&quot; @f@, because it's recursive. Also, non-recursive functions like @swap@
might be too big to inline (or even marked NOINLINE). We still want to exploit
the CPR property, and that is exactly what the worker/wrapper transformation
can do for us:

  $wf x n = case n of
    0 -&gt; case (x, 0) of -&gt; (a, b) -&gt; (# a, b #)
    _ -&gt; case f (x+1) (n-1) of (a, b) -&gt; (# a, b #)
  f x n = case $wf x n of (# a, b #) -&gt; (a, b)

where $wf readily simplifies (by case-of-known-constructor and inlining @f@) to:

  $wf x n = case n of
    0 -&gt; (# x, 0 #)
    _ -&gt; $wf (x+1) (n-1)

Now, a call site like @case f 1 2 of (a, b) -&gt; a + b@ can inline @f@ and
eliminate the heap-allocated pair constructor.

Note [Phase ordering]
~~~~~~~~~~~~~~~~~~~~~
We need to perform strictness analysis before CPR analysis, because that might
unbox some arguments, in turn leading to more constructed products.
Ideally, we would want the following pipeline:

1. Strictness
2. worker/wrapper (for strictness)
3. CPR
4. worker/wrapper (for CPR)

Currently, we omit 2. and anticipate the results of worker/wrapper.
See Note [CPR in a DataAlt case alternative]
and Note [CPR for binders that will be unboxed].
An additional w/w pass would simplify things, but probably add slight overhead.
So currently we have

1. Strictness
2. CPR
3. worker/wrapper (for strictness and CPR)
-}</span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">--</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- * Analysing programs</span><span>
</span><span id="line-106"></span><span class="hs-comment">--</span><span>
</span><span id="line-107"></span><span>
</span><span id="line-108"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalProgram"><span class="hs-identifier hs-type">cprAnalProgram</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-109"></span><span id="cprAnalProgram"><span class="annot"><span class="annottext">cprAnalProgram :: DynFlags -&gt; FamInstEnvs -&gt; CoreProgram -&gt; IO CoreProgram
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalProgram"><span class="hs-identifier hs-var hs-var">cprAnalProgram</span></a></span></span><span> </span><span id="local-6989586621680959349"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680959349"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680959348"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621680959348"><span class="hs-identifier hs-var">fam_envs</span></a></span></span><span> </span><span id="local-6989586621680959347"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680959347"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-110"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680959346"><span class="annot"><span class="annottext">env :: AnalEnv
</span><a href="#local-6989586621680959346"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#emptyAnalEnv"><span class="hs-identifier hs-var">emptyAnalEnv</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621680959348"><span class="hs-identifier hs-var">fam_envs</span></a></span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680959343"><span class="annot"><span class="annottext">binds_plus_cpr :: CoreProgram
</span><a href="#local-6989586621680959343"><span class="hs-identifier hs-var hs-var">binds_plus_cpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(AnalEnv, CoreProgram) -&gt; CoreProgram
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">((AnalEnv, CoreProgram) -&gt; CoreProgram)
-&gt; (AnalEnv, CoreProgram) -&gt; CoreProgram
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(AnalEnv -&gt; CoreBind -&gt; (AnalEnv, CoreBind))
-&gt; AnalEnv -&gt; CoreProgram -&gt; (AnalEnv, CoreProgram)
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBind -&gt; (AnalEnv, CoreBind)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalTopBind"><span class="hs-identifier hs-var">cprAnalTopBind</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959346"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680959347"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-112"></span><span>  </span><span class="annot"><span class="annottext">DynFlags -&gt; DumpFlag -&gt; String -&gt; DumpFormat -&gt; SDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#dumpIfSet_dyn"><span class="hs-identifier hs-var">dumpIfSet_dyn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680959349"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_cpr_signatures"><span class="hs-identifier hs-var">Opt_D_dump_cpr_signatures</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Cpr signatures&quot;</span></span><span> </span><span class="annot"><span class="annottext">DumpFormat
</span><a href="GHC.Utils.Error.html#FormatText"><span class="hs-identifier hs-var">FormatText</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; IO ()) -&gt; SDoc -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-113"></span><span>    </span><span class="annot"><span class="annottext">(IdInfo -&gt; SDoc) -&gt; CoreProgram -&gt; SDoc
</span><a href="GHC.Core.Utils.html#dumpIdInfoOfProgram"><span class="hs-identifier hs-var">dumpIdInfoOfProgram</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprSig -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">(CprSig -&gt; SDoc) -&gt; (IdInfo -&gt; CprSig) -&gt; IdInfo -&gt; SDoc
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; CprSig
</span><a href="GHC.Types.Id.Info.html#cprInfo"><span class="hs-identifier hs-var hs-var">cprInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680959343"><span class="hs-identifier hs-var">binds_plus_cpr</span></a></span><span>
</span><span id="line-114"></span><span>  </span><span class="hs-comment">-- See Note [Stamp out space leaks in demand analysis] in GHC.Core.Opt.DmdAnal</span><span>
</span><span id="line-115"></span><span>  </span><span class="annot"><span class="annottext">CoreProgram -&gt; ()
</span><a href="GHC.Core.Seq.html#seqBinds"><span class="hs-identifier hs-var">seqBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680959343"><span class="hs-identifier hs-var">binds_plus_cpr</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO CoreProgram -&gt; IO CoreProgram
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; IO CoreProgram
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621680959343"><span class="hs-identifier hs-var">binds_plus_cpr</span></a></span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span class="hs-comment">-- Analyse a (group of) top-level binding(s)</span><span>
</span><span id="line-118"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalTopBind"><span class="hs-identifier hs-type">cprAnalTopBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-119"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span>
</span><span id="line-120"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span id="cprAnalTopBind"><span class="annot"><span class="annottext">cprAnalTopBind :: AnalEnv -&gt; CoreBind -&gt; (AnalEnv, CoreBind)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalTopBind"><span class="hs-identifier hs-var hs-var">cprAnalTopBind</span></a></span></span><span> </span><span id="local-6989586621680959334"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959334"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680959332"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959332"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959331"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959331"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959330"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959329"><span class="hs-identifier hs-var">id'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959328"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-124"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959329"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959329"><span class="hs-identifier hs-var">id'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959328"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959328"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959330"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959330"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; AnalEnv
-&gt; CoreBndr
-&gt; Expr CoreBndr
-&gt; (CoreBndr, Expr CoreBndr, AnalEnv)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalBind"><span class="hs-identifier hs-var">cprAnalBind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959334"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959332"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959331"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalTopBind"><span class="hs-identifier hs-var">cprAnalTopBind</span></a></span><span> </span><span id="local-6989586621680959325"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959325"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680959323"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959323"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959322"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959321"><span class="hs-identifier hs-var">pairs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-129"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959322"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959322"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959321"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959321"><span class="hs-identifier hs-var">pairs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="GHC.Core.Opt.CprAnal.html#cprFix"><span class="hs-identifier hs-var">cprFix</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#TopLevel"><span class="hs-identifier hs-var">TopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959325"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959323"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-130"></span><span>
</span><span id="line-131"></span><span class="hs-comment">--</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- * Analysing expressions</span><span>
</span><span id="line-133"></span><span class="hs-comment">--</span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span class="hs-comment">-- | The abstract semantic function &#10214;_&#10215; : Expr -&gt; Env -&gt; A from</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- &quot;Constructed Product Result Analysis for Haskell&quot;</span><span>
</span><span id="line-137"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-type">cprAnal</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-type">cprAnal'</span></a></span><span>
</span><span id="line-138"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>            </span><span class="hs-comment">-- ^ expression to be denoted by a 'CprType'</span><span>
</span><span id="line-140"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ the updated expression and its 'CprType'</span><span>
</span><span id="line-141"></span><span>
</span><span id="line-142"></span><span id="cprAnal"><span class="annot"><span class="annottext">cprAnal :: AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var hs-var">cprAnal</span></a></span></span><span> </span><span id="local-6989586621680959316"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959316"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959315"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959315"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTraceWith &quot;cprAnal&quot; (\res -&gt; ppr (fst (res)) $$ ppr e) $</span><span>
</span><span id="line-143"></span><span>                  </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959316"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959315"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-144"></span><span>
</span><span id="line-145"></span><span id="cprAnal%27"><span class="annot"><span class="annottext">cprAnal' :: AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var hs-var">cprAnal'</span></a></span></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-type">Lit</span></a></span><span> </span><span id="local-6989586621680959313"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680959313"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#topCprType"><span class="hs-identifier hs-var">topCprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; Expr CoreBndr
forall b. Literal -&gt; Expr b
</span><a href="GHC.Core.html#Lit"><span class="hs-identifier hs-var">Lit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680959313"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-146"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span id="local-6989586621680959310"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959310"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#topCprType"><span class="hs-identifier hs-var">topCprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Expr CoreBndr
forall b. Type -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959310"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- Doesn't happen, in fact</span><span>
</span><span id="line-147"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span id="local-6989586621680959308"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680959308"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#topCprType"><span class="hs-identifier hs-var">topCprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Expr CoreBndr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680959308"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959307"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959307"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680959305"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959305"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680959304"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680959304"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959303"><span class="hs-identifier hs-var">cpr_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Coercion -&gt; Expr CoreBndr
forall b. Expr b -&gt; Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959302"><span class="hs-identifier hs-var">e'</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621680959304"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-151"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-152"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959303"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959303"><span class="hs-identifier hs-var">cpr_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959302"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959302"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959307"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959305"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959301"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959301"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680959299"><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680959299"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680959298"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959298"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959297"><span class="hs-identifier hs-var">cpr_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Tickish CoreBndr -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish CoreBndr
</span><a href="#local-6989586621680959299"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959296"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-156"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-157"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959297"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959297"><span class="hs-identifier hs-var">cpr_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959296"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959296"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959301"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959298"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-158"></span><span>
</span><span id="line-159"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959295"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959295"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959294"><span class="annot"><span class="annottext">e :: Expr CoreBndr
</span><a href="#local-6989586621680959294"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr
-&gt; [Expr CoreBndr]
-&gt; [CprType]
-&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-var">cprAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959295"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959294"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-161"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959291"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959291"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959290"><span class="annot"><span class="annottext">e :: Expr CoreBndr
</span><a href="#local-6989586621680959290"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr
-&gt; [Expr CoreBndr]
-&gt; [CprType]
-&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-var">cprAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959291"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959290"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959288"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959288"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680959286"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span></span><span> </span><span id="local-6989586621680959285"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959285"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-165"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-166"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959283"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959283"><span class="hs-identifier hs-var">body_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959282"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959282"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959288"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959285"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-167"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959283"><span class="hs-identifier hs-var">body_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959282"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-169"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959281"><span class="hs-identifier hs-var">lam_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959280"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-171"></span><span>    </span><span id="local-6989586621680959279"><span class="annot"><span class="annottext">env' :: AnalEnv
</span><a href="#local-6989586621680959279"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; Demand -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvForDemand"><span class="hs-identifier hs-var">extendSigEnvForDemand</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959288"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Demand
</span><a href="GHC.Types.Id.html#idDemandInfo"><span class="hs-identifier hs-var">idDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959286"><span class="hs-identifier hs-var">var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-172"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959276"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959276"><span class="hs-identifier hs-var">body_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959280"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959280"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959279"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959285"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-173"></span><span>    </span><span id="local-6989586621680959281"><span class="annot"><span class="annottext">lam_ty :: CprType
</span><a href="#local-6989586621680959281"><span class="hs-identifier hs-var hs-var">lam_ty</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; CprType
</span><a href="GHC.Types.Cpr.html#abstractCprTy"><span class="hs-identifier hs-var">abstractCprTy</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959276"><span class="hs-identifier hs-var">body_ty</span></a></span><span>
</span><span id="line-174"></span><span>
</span><span id="line-175"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959274"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959274"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680959272"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959272"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680959271"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959271"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680959270"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959270"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680959269"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680959269"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959268"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
-&gt; CoreBndr -&gt; Type -&gt; [Alt CoreBndr] -&gt; Expr CoreBndr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959267"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959271"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959270"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680959266"><span class="hs-identifier hs-var">alts'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-178"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959267"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959267"><span class="hs-identifier hs-var">scrut'</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959274"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959272"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-179"></span><span>    </span><span class="hs-comment">-- Regardless whether scrut had the CPR property or not, the case binder</span><span>
</span><span id="line-180"></span><span>    </span><span class="hs-comment">-- certainly has it. See 'extendEnvForDataAlt'.</span><span>
</span><span id="line-181"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959265"><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959265"><span class="hs-identifier hs-var">alt_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959266"><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680959266"><span class="hs-identifier hs-var">alts'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Alt CoreBndr -&gt; (CprType, Alt CoreBndr))
-&gt; [Alt CoreBndr] -&gt; ([CprType], [Alt CoreBndr])
forall a b c. (a -&gt; (b, c)) -&gt; [a] -&gt; ([b], [c])
</span><a href="GHC.Utils.Misc.html#mapAndUnzip"><span class="hs-identifier hs-var">mapAndUnzip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr
-&gt; CoreBndr
-&gt; Alt CoreBndr
-&gt; (CprType, Alt CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalAlt"><span class="hs-identifier hs-var">cprAnalAlt</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959274"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959272"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959271"><span class="hs-identifier hs-var">case_bndr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Alt CoreBndr]
</span><a href="#local-6989586621680959269"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-182"></span><span>    </span><span id="local-6989586621680959268"><span class="annot"><span class="annottext">res_ty :: CprType
</span><a href="#local-6989586621680959268"><span class="hs-identifier hs-var hs-var">res_ty</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CprType -&gt; CprType -&gt; CprType) -&gt; CprType -&gt; [CprType] -&gt; CprType
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CprType -&gt; CprType -&gt; CprType
</span><a href="GHC.Types.Cpr.html#lubCprType"><span class="hs-identifier hs-var">lubCprType</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#botCprType"><span class="hs-identifier hs-var">botCprType</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959265"><span class="hs-identifier hs-var">alt_tys</span></a></span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959258"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959258"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680959256"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959256"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959255"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959255"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680959254"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959254"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959253"><span class="hs-identifier hs-var">body_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959252"><span class="hs-identifier hs-var">id'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959251"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959250"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-187"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959252"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959252"><span class="hs-identifier hs-var">id'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959251"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959251"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959249"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959249"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; AnalEnv
-&gt; CoreBndr
-&gt; Expr CoreBndr
-&gt; (CoreBndr, Expr CoreBndr, AnalEnv)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalBind"><span class="hs-identifier hs-var">cprAnalBind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959258"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959256"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959255"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-188"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959253"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959253"><span class="hs-identifier hs-var">body_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959250"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959250"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959249"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959254"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-189"></span><span>
</span><span id="line-190"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnal%27"><span class="hs-identifier hs-var">cprAnal'</span></a></span><span> </span><span id="local-6989586621680959247"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959247"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680959246"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959246"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680959245"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959245"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959244"><span class="hs-identifier hs-var">body_ty</span></a></span><span> </span><span class="annot"><span class="annottext">CprType -&gt; (CprType, Expr CoreBndr) -&gt; (CprType, Expr CoreBndr)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959244"><span class="hs-identifier hs-var">body_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; Expr CoreBndr -&gt; Expr CoreBndr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959243"><span class="hs-identifier hs-var">pairs'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959242"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-193"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959241"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959241"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959243"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959243"><span class="hs-identifier hs-var">pairs'</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="GHC.Core.Opt.CprAnal.html#cprFix"><span class="hs-identifier hs-var">cprFix</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="GHC.Types.Basic.html#NotTopLevel"><span class="hs-identifier hs-var">NotTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959247"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959246"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-194"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959244"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959244"><span class="hs-identifier hs-var">body_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959242"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959242"><span class="hs-identifier hs-var">body'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959241"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959245"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalAlt"><span class="hs-identifier hs-type">cprAnalAlt</span></a></span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-comment">-- ^ scrutinee</span><span>
</span><span id="line-199"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>       </span><span class="hs-comment">-- ^ case binder</span><span>
</span><span id="line-200"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#Alt"><span class="hs-identifier hs-type">Alt</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span>  </span><span class="hs-comment">-- ^ current alternative</span><span>
</span><span id="line-201"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Alt"><span class="hs-identifier hs-type">Alt</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-202"></span><span id="cprAnalAlt"><span class="annot"><span class="annottext">cprAnalAlt :: AnalEnv
-&gt; Expr CoreBndr
-&gt; CoreBndr
-&gt; Alt CoreBndr
-&gt; (CprType, Alt CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalAlt"><span class="hs-identifier hs-var hs-var">cprAnalAlt</span></a></span></span><span> </span><span id="local-6989586621680959238"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959238"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959237"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959237"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680959236"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959236"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959235"><span class="annot"><span class="annottext">con :: AltCon
</span><a href="#local-6989586621680959235"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-type">DataAlt</span></a></span><span> </span><span id="local-6989586621680959233"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959233"><span class="hs-identifier hs-var">dc</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span id="local-6989586621680959232"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959232"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680959231"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959231"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span>  </span><span class="hs-comment">-- See 'extendEnvForDataAlt' and Note [CPR in a DataAlt case alternative]</span><span>
</span><span id="line-204"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959230"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680959235"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959232"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959229"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-206"></span><span>    </span><span id="local-6989586621680959228"><span class="annot"><span class="annottext">env_alt :: AnalEnv
</span><a href="#local-6989586621680959228"><span class="hs-identifier hs-var hs-var">env_alt</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr -&gt; CoreBndr -&gt; DataCon -&gt; [CoreBndr] -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendEnvForDataAlt"><span class="hs-identifier hs-var">extendEnvForDataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959238"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959237"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959236"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959233"><span class="hs-identifier hs-var">dc</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959232"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-207"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959230"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959230"><span class="hs-identifier hs-var">rhs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959229"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959229"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959228"><span class="hs-identifier hs-var">env_alt</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959231"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-208"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalAlt"><span class="hs-identifier hs-var">cprAnalAlt</span></a></span><span> </span><span id="local-6989586621680959226"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959226"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959225"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680959225"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680959224"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959224"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680959223"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959223"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959222"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680959225"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959224"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959221"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-211"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959222"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959222"><span class="hs-identifier hs-var">rhs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959221"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959221"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959226"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959223"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- * CPR transformer</span><span>
</span><span id="line-215"></span><span class="hs-comment">--</span><span>
</span><span id="line-216"></span><span>
</span><span id="line-217"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-type">cprAnalApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreArg"><span class="hs-identifier hs-type">CoreArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span id="cprAnalApp"><span class="annot"><span class="annottext">cprAnalApp :: AnalEnv
-&gt; Expr CoreBndr
-&gt; [Expr CoreBndr]
-&gt; [CprType]
-&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-var hs-var">cprAnalApp</span></a></span></span><span> </span><span id="local-6989586621680959219"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959218"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680959217"><span class="annot"><span class="annottext">[Expr CoreBndr]
</span><a href="#local-6989586621680959217"><span class="hs-identifier hs-var">args'</span></a></span></span><span> </span><span id="local-6989586621680959216"><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959216"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span>
</span><span id="line-219"></span><span>  </span><span class="hs-comment">-- Collect CprTypes for (value) args (inlined collectArgs):</span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680959215"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959215"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680959214"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959214"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="GHC.Core.html#isTypeArg"><span class="hs-identifier hs-var">isTypeArg</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959214"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="hs-comment">-- Don't analyse Type args</span><span>
</span><span id="line-221"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr
-&gt; [Expr CoreBndr]
-&gt; [CprType]
-&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-var">cprAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959215"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959214"><span class="hs-identifier hs-var">arg</span></a></span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; [Expr CoreBndr] -&gt; [Expr CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Expr CoreBndr]
</span><a href="#local-6989586621680959217"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959216"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-222"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680959212"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959212"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680959211"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959211"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-223"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959210"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959210"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959209"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959209"><span class="hs-identifier hs-var">arg'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959211"><span class="hs-identifier hs-var">arg</span></a></span><span>
</span><span id="line-224"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; Expr CoreBndr
-&gt; [Expr CoreBndr]
-&gt; [CprType]
-&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalApp"><span class="hs-identifier hs-var">cprAnalApp</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959212"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959209"><span class="hs-identifier hs-var">arg'</span></a></span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; [Expr CoreBndr] -&gt; [Expr CoreBndr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Expr CoreBndr]
</span><a href="#local-6989586621680959217"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959210"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="annot"><span class="annottext">CprType -&gt; [CprType] -&gt; [CprType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959216"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-225"></span><span>
</span><span id="line-226"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680959208"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959208"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-227"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; [CprType] -&gt; CprType
</span><a href="GHC.Core.Opt.CprAnal.html#cprTransform"><span class="hs-identifier hs-var">cprTransform</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959208"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959216"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; [Expr CoreBndr] -&gt; Expr CoreBndr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">[Expr CoreBndr]
</span><a href="#local-6989586621680959217"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-228"></span><span>
</span><span id="line-229"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-comment">-- e is not an App and not a Var</span><span>
</span><span id="line-230"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959205"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959205"><span class="hs-identifier hs-var">e_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959204"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959204"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959219"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959218"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-231"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType -&gt; Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#applyCprTy"><span class="hs-identifier hs-var">applyCprTy</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959205"><span class="hs-identifier hs-var">e_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CprType] -&gt; Arity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Arity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959216"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; [Expr CoreBndr] -&gt; Expr CoreBndr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959204"><span class="hs-identifier hs-var">e'</span></a></span><span> </span><span class="annot"><span class="annottext">[Expr CoreBndr]
</span><a href="#local-6989586621680959217"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprTransform"><span class="hs-identifier hs-type">cprTransform</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>   </span><span class="hs-comment">-- ^ The analysis environment</span><span>
</span><span id="line-234"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>        </span><span class="hs-comment">-- ^ The function</span><span>
</span><span id="line-235"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ info about incoming /value/ arguments</span><span>
</span><span id="line-236"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span>   </span><span class="hs-comment">-- ^ The demand type of the application</span><span>
</span><span id="line-237"></span><span id="cprTransform"><span class="annot"><span class="annottext">cprTransform :: AnalEnv -&gt; CoreBndr -&gt; [CprType] -&gt; CprType
</span><a href="GHC.Core.Opt.CprAnal.html#cprTransform"><span class="hs-identifier hs-var hs-var">cprTransform</span></a></span></span><span> </span><span id="local-6989586621680959201"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959201"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959200"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959199"><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959199"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-238"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;cprTransform&quot; (vcat [ppr id, ppr args, ppr sig])</span><span>
</span><span id="line-239"></span><span>    </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959198"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-240"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-241"></span><span>    </span><span id="local-6989586621680959198"><span class="annot"><span class="annottext">sig :: CprType
</span><a href="#local-6989586621680959198"><span class="hs-identifier hs-var hs-var">sig</span></a></span></span><span>
</span><span id="line-242"></span><span>      </span><span class="hs-comment">-- Top-level binding, local let-binding, lambda arg or case binder</span><span>
</span><span id="line-243"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680959195"><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959195"><span class="hs-identifier hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; Maybe CprSig
</span><a href="GHC.Core.Opt.CprAnal.html#lookupSigEnv"><span class="hs-identifier hs-var">lookupSigEnv</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959201"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-244"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#applyCprTy"><span class="hs-identifier hs-var">applyCprTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprSig -&gt; CprType
</span><a href="GHC.Types.Cpr.html#getCprSig"><span class="hs-identifier hs-var hs-var">getCprSig</span></a></span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959195"><span class="hs-identifier hs-var">sig</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CprType] -&gt; Arity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Arity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959199"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>      </span><span class="hs-comment">-- CPR transformers for special Ids</span><span>
</span><span id="line-246"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680959192"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959192"><span class="hs-identifier hs-var">cpr_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; [CprType] -&gt; Maybe CprType
</span><a href="GHC.Core.Opt.CprAnal.html#cprTransformSpecial"><span class="hs-identifier hs-var">cprTransformSpecial</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959199"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-247"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959192"><span class="hs-identifier hs-var">cpr_ty</span></a></span><span>
</span><span id="line-248"></span><span>      </span><span class="hs-comment">-- See Note [CPR for data structures]</span><span>
</span><span id="line-249"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680959190"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959190"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprDataStructureUnfolding_maybe"><span class="hs-identifier hs-var">cprDataStructureUnfolding_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-250"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CprType, Expr CoreBndr) -&gt; CprType
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">((CprType, Expr CoreBndr) -&gt; CprType)
-&gt; (CprType, Expr CoreBndr) -&gt; CprType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959201"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959190"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-251"></span><span>      </span><span class="hs-comment">-- Imported function or data con worker</span><span>
</span><span id="line-252"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isGlobalId"><span class="hs-identifier hs-var">isGlobalId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-253"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#applyCprTy"><span class="hs-identifier hs-var">applyCprTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprSig -&gt; CprType
</span><a href="GHC.Types.Cpr.html#getCprSig"><span class="hs-identifier hs-var hs-var">getCprSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig
</span><a href="GHC.Types.Id.html#idCprInfo"><span class="hs-identifier hs-var">idCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959200"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CprType] -&gt; Arity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Arity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959199"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-254"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-255"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#topCprType"><span class="hs-identifier hs-var">topCprType</span></a></span><span>
</span><span id="line-256"></span><span>
</span><span id="line-257"></span><span class="hs-comment">-- | CPR transformers for special Ids</span><span>
</span><span id="line-258"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprTransformSpecial"><span class="hs-identifier hs-type">cprTransformSpecial</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#CprType"><span class="hs-identifier hs-type">CprType</span></a></span><span>
</span><span id="line-259"></span><span id="cprTransformSpecial"><span class="annot"><span class="annottext">cprTransformSpecial :: CoreBndr -&gt; [CprType] -&gt; Maybe CprType
</span><a href="GHC.Core.Opt.CprAnal.html#cprTransformSpecial"><span class="hs-identifier hs-var hs-var">cprTransformSpecial</span></a></span></span><span> </span><span id="local-6989586621680959186"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959186"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959185"><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959185"><span class="hs-identifier hs-var">args</span></a></span></span><span>
</span><span id="line-260"></span><span>  </span><span class="hs-comment">-- See Note [Simplification of runRW#] in GHC.CoreToStg.Prep</span><span>
</span><span id="line-261"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Unique
</span><a href="GHC.Types.Id.html#idUnique"><span class="hs-identifier hs-var">idUnique</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959186"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#runRWKey"><span class="hs-identifier hs-var">runRWKey</span></a></span><span> </span><span class="hs-comment">-- `runRW (\s -&gt; e)`</span><span>
</span><span id="line-262"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621680959183"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959183"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CprType]
</span><a href="#local-6989586621680959185"><span class="hs-identifier hs-var">args</span></a></span><span>           </span><span class="hs-comment">-- `\s -&gt; e` has CPR type `arg` (e.g. `. -&gt; 2`)</span><span>
</span><span id="line-263"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; Maybe CprType
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(CprType -&gt; Maybe CprType) -&gt; CprType -&gt; Maybe CprType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CprType -&gt; Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#applyCprTy"><span class="hs-identifier hs-var">applyCprTy</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959183"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span> </span><span class="hs-comment">-- `e` has CPR type `2`</span><span>
</span><span id="line-264"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-265"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CprType
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-266"></span><span>
</span><span id="line-267"></span><span class="hs-comment">--</span><span>
</span><span id="line-268"></span><span class="hs-comment">-- * Bindings</span><span>
</span><span id="line-269"></span><span class="hs-comment">--</span><span>
</span><span id="line-270"></span><span>
</span><span id="line-271"></span><span class="hs-comment">-- Recursive bindings</span><span>
</span><span id="line-272"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprFix"><span class="hs-identifier hs-type">cprFix</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>
</span><span id="line-273"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>                    </span><span class="hs-comment">-- Does not include bindings for this binding</span><span>
</span><span id="line-274"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-275"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Binders annotated with CPR info</span><span>
</span><span id="line-276"></span><span id="cprFix"><span class="annot"><span class="annottext">cprFix :: TopLevelFlag
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="GHC.Core.Opt.CprAnal.html#cprFix"><span class="hs-identifier hs-var hs-var">cprFix</span></a></span></span><span> </span><span id="local-6989586621680959182"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680959182"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621680959181"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959181"><span class="hs-identifier hs-var">orig_env</span></a></span></span><span> </span><span id="local-6989586621680959180"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959180"><span class="hs-identifier hs-var">orig_pairs</span></a></span></span><span>
</span><span id="line-277"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="#local-6989586621680959179"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959178"><span class="hs-identifier hs-var">init_env</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959177"><span class="hs-identifier hs-var">init_pairs</span></a></span><span>
</span><span id="line-278"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-279"></span><span>    </span><span id="local-6989586621680959176"><span class="annot"><span class="annottext">init_sig :: CoreBndr -&gt; Expr CoreBndr -&gt; CprSig
</span><a href="#local-6989586621680959176"><span class="hs-identifier hs-var hs-var">init_sig</span></a></span></span><span> </span><span id="local-6989586621680959175"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959175"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959174"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959174"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-280"></span><span>      </span><span class="hs-comment">-- See Note [CPR for data structures]</span><span>
</span><span id="line-281"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#isDataStructure"><span class="hs-identifier hs-var">isDataStructure</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959175"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959174"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="GHC.Types.Cpr.html#topCprSig"><span class="hs-identifier hs-var">topCprSig</span></a></span><span>
</span><span id="line-282"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; CprResult -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#mkCprSig"><span class="hs-identifier hs-var">mkCprSig</span></a></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">CprResult
</span><a href="GHC.Types.Cpr.html#botCpr"><span class="hs-identifier hs-var">botCpr</span></a></span><span>
</span><span id="line-283"></span><span>    </span><span class="hs-comment">-- See Note [Initialising strictness] in GHC.Core.Opt.DmdAnal</span><span>
</span><span id="line-284"></span><span>    </span><span id="local-6989586621680959169"><span class="annot"><span class="annottext">orig_virgin :: Bool
</span><a href="#local-6989586621680959169"><span class="hs-identifier hs-var hs-var">orig_virgin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var hs-var">ae_virgin</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959181"><span class="hs-identifier hs-var">orig_env</span></a></span><span>
</span><span id="line-285"></span><span>    </span><span id="local-6989586621680959177"><span class="annot"><span class="annottext">init_pairs :: [(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959177"><span class="hs-identifier hs-var hs-var">init_pairs</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959169"><span class="hs-identifier hs-var">orig_virgin</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdCprInfo"><span class="hs-identifier hs-var">setIdCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959166"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; CprSig
</span><a href="#local-6989586621680959176"><span class="hs-identifier hs-var">init_sig</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959166"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959165"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959165"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959166"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959166"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959165"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959165"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959180"><span class="hs-identifier hs-var">orig_pairs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-286"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959180"><span class="hs-identifier hs-var">orig_pairs</span></a></span><span>
</span><span id="line-287"></span><span>    </span><span id="local-6989586621680959178"><span class="annot"><span class="annottext">init_env :: AnalEnv
</span><a href="#local-6989586621680959178"><span class="hs-identifier hs-var hs-var">init_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; [CoreBndr] -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvList"><span class="hs-identifier hs-var">extendSigEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959181"><span class="hs-identifier hs-var">orig_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((CoreBndr, Expr CoreBndr) -&gt; CoreBndr)
-&gt; [(CoreBndr, Expr CoreBndr)] -&gt; [CoreBndr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr) -&gt; CoreBndr
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959177"><span class="hs-identifier hs-var">init_pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-288"></span><span>
</span><span id="line-289"></span><span>    </span><span class="hs-comment">-- The fixed-point varies the idCprInfo field of the binders and and their</span><span>
</span><span id="line-290"></span><span>    </span><span class="hs-comment">-- entries in the AnalEnv, and terminates if that annotation does not change</span><span>
</span><span id="line-291"></span><span>    </span><span class="hs-comment">-- any more.</span><span>
</span><span id="line-292"></span><span>    </span><span class="annot"><a href="#local-6989586621680959179"><span class="hs-identifier hs-type">loop</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>    </span><span id="local-6989586621680959179"><span class="annot"><span class="annottext">loop :: Arity
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="#local-6989586621680959179"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span id="local-6989586621680959163"><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621680959163"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680959162"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959162"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959161"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959161"><span class="hs-identifier hs-var">pairs</span></a></span></span><span>
</span><span id="line-294"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959160"><span class="hs-identifier hs-var">found_fixpoint</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959159"><span class="hs-identifier hs-var">reset_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959158"><span class="hs-identifier hs-var">pairs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Arity
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="#local-6989586621680959179"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621680959163"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Arity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959156"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959158"><span class="hs-identifier hs-var">pairs'</span></a></span><span>
</span><span id="line-296"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-297"></span><span>        </span><span class="hs-comment">-- In all but the first iteration, delete the virgin flag</span><span>
</span><span id="line-298"></span><span>        </span><span class="hs-comment">-- See Note [Initialising strictness] in GHC.Core.Opt.DmdAnal</span><span>
</span><span id="line-299"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680959156"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959156"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959158"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959158"><span class="hs-identifier hs-var">pairs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="#local-6989586621680959153"><span class="hs-identifier hs-var">step</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; (AnalEnv -&gt; AnalEnv) -&gt; AnalEnv -&gt; AnalEnv
forall a. Bool -&gt; (a -&gt; a) -&gt; a -&gt; a
</span><a href="GHC.Utils.Misc.html#applyWhen"><span class="hs-identifier hs-var">applyWhen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity
</span><a href="#local-6989586621680959163"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#nonVirgin"><span class="hs-identifier hs-var">nonVirgin</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959162"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959161"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-300"></span><span>        </span><span class="hs-comment">-- Make sure we reset the virgin flag to what it was when we are stable</span><span>
</span><span id="line-301"></span><span>        </span><span id="local-6989586621680959159"><span class="annot"><span class="annottext">reset_env' :: AnalEnv
</span><a href="#local-6989586621680959159"><span class="hs-identifier hs-var hs-var">reset_env'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959156"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_virgin :: Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var">ae_virgin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959169"><span class="hs-identifier hs-var">orig_virgin</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-302"></span><span>        </span><span id="local-6989586621680959160"><span class="annot"><span class="annottext">found_fixpoint :: Bool
</span><a href="#local-6989586621680959160"><span class="hs-identifier hs-var hs-var">found_fixpoint</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((CoreBndr, Expr CoreBndr) -&gt; CprSig)
-&gt; [(CoreBndr, Expr CoreBndr)] -&gt; [CprSig]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig
</span><a href="GHC.Types.Id.html#idCprInfo"><span class="hs-identifier hs-var">idCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; CprSig)
-&gt; ((CoreBndr, Expr CoreBndr) -&gt; CoreBndr)
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; CprSig
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr) -&gt; CoreBndr
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959158"><span class="hs-identifier hs-var">pairs'</span></a></span><span> </span><span class="annot"><span class="annottext">[CprSig] -&gt; [CprSig] -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">((CoreBndr, Expr CoreBndr) -&gt; CprSig)
-&gt; [(CoreBndr, Expr CoreBndr)] -&gt; [CprSig]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig
</span><a href="GHC.Types.Id.html#idCprInfo"><span class="hs-identifier hs-var">idCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; CprSig)
-&gt; ((CoreBndr, Expr CoreBndr) -&gt; CoreBndr)
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; CprSig
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreBndr, Expr CoreBndr) -&gt; CoreBndr
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959161"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-303"></span><span>
</span><span id="line-304"></span><span>    </span><span class="annot"><a href="#local-6989586621680959153"><span class="hs-identifier hs-type">step</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>    </span><span id="local-6989586621680959153"><span class="annot"><span class="annottext">step :: AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
</span><a href="#local-6989586621680959153"><span class="hs-identifier hs-var hs-var">step</span></a></span></span><span> </span><span id="local-6989586621680959145"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959145"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959144"><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959144"><span class="hs-identifier hs-var">pairs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(AnalEnv
 -&gt; (CoreBndr, Expr CoreBndr)
 -&gt; (AnalEnv, (CoreBndr, Expr CoreBndr)))
-&gt; AnalEnv
-&gt; [(CoreBndr, Expr CoreBndr)]
-&gt; (AnalEnv, [(CoreBndr, Expr CoreBndr)])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; (AnalEnv, (CoreBndr, Expr CoreBndr))
</span><a href="#local-6989586621680959143"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959145"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, Expr CoreBndr)]
</span><a href="#local-6989586621680959144"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-306"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-307"></span><span>        </span><span id="local-6989586621680959143"><span class="annot"><span class="annottext">go :: AnalEnv
-&gt; (CoreBndr, Expr CoreBndr)
-&gt; (AnalEnv, (CoreBndr, Expr CoreBndr))
</span><a href="#local-6989586621680959143"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680959142"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959142"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959141"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959141"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959140"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959140"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959139"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959138"><span class="hs-identifier hs-var">id'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959137"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-308"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-309"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621680959138"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959138"><span class="hs-identifier hs-var">id'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959137"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959137"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959139"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959139"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
-&gt; AnalEnv
-&gt; CoreBndr
-&gt; Expr CoreBndr
-&gt; (CoreBndr, Expr CoreBndr, AnalEnv)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalBind"><span class="hs-identifier hs-var">cprAnalBind</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680959182"><span class="hs-identifier hs-var">top_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959142"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959141"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959140"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-310"></span><span>
</span><span id="line-311"></span><span class="hs-comment">-- | Process the RHS of the binding for a sensible arity, add the CPR signature</span><span>
</span><span id="line-312"></span><span class="hs-comment">-- to the Id, and augment the environment with the signature as well.</span><span>
</span><span id="line-313"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprAnalBind"><span class="hs-identifier hs-type">cprAnalBind</span></a></span><span>
</span><span id="line-314"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TopLevelFlag"><span class="hs-identifier hs-type">TopLevelFlag</span></a></span><span>
</span><span id="line-315"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-316"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-317"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-318"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-319"></span><span id="cprAnalBind"><span class="annot"><span class="annottext">cprAnalBind :: TopLevelFlag
-&gt; AnalEnv
-&gt; CoreBndr
-&gt; Expr CoreBndr
-&gt; (CoreBndr, Expr CoreBndr, AnalEnv)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnalBind"><span class="hs-identifier hs-var hs-var">cprAnalBind</span></a></span></span><span> </span><span id="local-6989586621680959136"><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680959136"><span class="hs-identifier hs-var">top_lvl</span></a></span></span><span> </span><span id="local-6989586621680959135"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959135"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959134"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959133"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959133"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-320"></span><span>  </span><span class="hs-comment">-- See Note [CPR for data structures]</span><span>
</span><span id="line-321"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#isDataStructure"><span class="hs-identifier hs-var">isDataStructure</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959133"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-322"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959133"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959135"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Data structure =&gt; no code =&gt; need to analyse rhs</span><span>
</span><span id="line-323"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-324"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959132"><span class="hs-identifier hs-var">id'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959131"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959130"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-325"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-326"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680959129"><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959129"><span class="hs-identifier hs-var">rhs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959131"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959131"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; Expr CoreBndr -&gt; (CprType, Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprAnal"><span class="hs-identifier hs-var">cprAnal</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959135"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959133"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-327"></span><span>    </span><span class="hs-comment">-- possibly trim thunk CPR info</span><span>
</span><span id="line-328"></span><span>    </span><span id="local-6989586621680959128"><span class="annot"><span class="annottext">rhs_ty' :: CprType
</span><a href="#local-6989586621680959128"><span class="hs-identifier hs-var hs-var">rhs_ty'</span></a></span></span><span>
</span><span id="line-329"></span><span>      </span><span class="hs-comment">-- See Note [CPR for thunks]</span><span>
</span><span id="line-330"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959127"><span class="hs-identifier hs-var">stays_thunk</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; CprType
</span><a href="GHC.Types.Cpr.html#trimCprTy"><span class="hs-identifier hs-var">trimCprTy</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959129"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span>
</span><span id="line-331"></span><span>      </span><span class="hs-comment">-- See Note [CPR for sum types]</span><span>
</span><span id="line-332"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959125"><span class="hs-identifier hs-var">returns_sum</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType -&gt; CprType
</span><a href="GHC.Types.Cpr.html#trimCprTy"><span class="hs-identifier hs-var">trimCprTy</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959129"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span>
</span><span id="line-333"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959129"><span class="hs-identifier hs-var">rhs_ty</span></a></span><span>
</span><span id="line-334"></span><span>    </span><span class="hs-comment">-- See Note [Arity trimming for CPR signatures]</span><span>
</span><span id="line-335"></span><span>    </span><span id="local-6989586621680959124"><span class="annot"><span class="annottext">sig :: CprSig
</span><a href="#local-6989586621680959124"><span class="hs-identifier hs-var hs-var">sig</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; CprType -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#mkCprSigForArity"><span class="hs-identifier hs-var">mkCprSigForArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Arity
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959128"><span class="hs-identifier hs-var">rhs_ty'</span></a></span><span>
</span><span id="line-336"></span><span>    </span><span id="local-6989586621680959132"><span class="annot"><span class="annottext">id' :: CoreBndr
</span><a href="#local-6989586621680959132"><span class="hs-identifier hs-var hs-var">id'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig -&gt; CoreBndr
</span><a href="GHC.Types.Id.html#setIdCprInfo"><span class="hs-identifier hs-var">setIdCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959124"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-337"></span><span>    </span><span id="local-6989586621680959130"><span class="annot"><span class="annottext">env' :: AnalEnv
</span><a href="#local-6989586621680959130"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; CprSig -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnv"><span class="hs-identifier hs-var">extendSigEnv</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959135"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959124"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-338"></span><span>
</span><span id="line-339"></span><span>    </span><span class="hs-comment">-- See Note [CPR for thunks]</span><span>
</span><span id="line-340"></span><span>    </span><span id="local-6989586621680959127"><span class="annot"><span class="annottext">stays_thunk :: Bool
</span><a href="#local-6989586621680959127"><span class="hs-identifier hs-var hs-var">stays_thunk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959120"><span class="hs-identifier hs-var">is_thunk</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959118"><span class="hs-identifier hs-var">not_strict</span></a></span><span>
</span><span id="line-341"></span><span>    </span><span id="local-6989586621680959120"><span class="annot"><span class="annottext">is_thunk :: Bool
</span><a href="#local-6989586621680959120"><span class="hs-identifier hs-var hs-var">is_thunk</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier hs-var">exprIsHNF</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959133"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>    </span><span id="local-6989586621680959118"><span class="annot"><span class="annottext">not_strict :: Bool
</span><a href="#local-6989586621680959118"><span class="hs-identifier hs-var hs-var">not_strict</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Demand -&gt; Bool
forall s u. JointDmd (Str s) (Use u) -&gt; Bool
</span><a href="GHC.Types.Demand.html#isStrictDmd"><span class="hs-identifier hs-var">isStrictDmd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Demand
</span><a href="GHC.Types.Id.html#idDemandInfo"><span class="hs-identifier hs-var">idDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-343"></span><span>    </span><span class="hs-comment">-- See Note [CPR for sum types]</span><span>
</span><span id="line-344"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoBinder]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959114"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959114"><span class="hs-identifier hs-var">ret_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyCoBinder], Type)
</span><a href="GHC.Core.Type.html#splitPiTys"><span class="hs-identifier hs-var">splitPiTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959134"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-345"></span><span>    </span><span id="local-6989586621680959111"><span class="annot"><span class="annottext">not_a_prod :: Bool
</span><a href="#local-6989586621680959111"><span class="hs-identifier hs-var hs-var">not_a_prod</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe DataConAppContext -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isNothing"><span class="hs-identifier hs-var">isNothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FamInstEnvs -&gt; Type -&gt; Maybe DataConAppContext
</span><a href="GHC.Core.Opt.WorkWrap.Utils.html#deepSplitProductType_maybe"><span class="hs-identifier hs-var">deepSplitProductType_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; FamInstEnvs
</span><a href="GHC.Core.Opt.CprAnal.html#ae_fam_envs"><span class="hs-identifier hs-var hs-var">ae_fam_envs</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959135"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680959114"><span class="hs-identifier hs-var">ret_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-346"></span><span>    </span><span id="local-6989586621680959125"><span class="annot"><span class="annottext">returns_sum :: Bool
</span><a href="#local-6989586621680959125"><span class="hs-identifier hs-var hs-var">returns_sum</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TopLevelFlag -&gt; Bool
</span><a href="GHC.Types.Basic.html#isTopLevel"><span class="hs-identifier hs-var">isTopLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TopLevelFlag
</span><a href="#local-6989586621680959136"><span class="hs-identifier hs-var">top_lvl</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959111"><span class="hs-identifier hs-var">not_a_prod</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#isDataStructure"><span class="hs-identifier hs-type">isDataStructure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-349"></span><span class="hs-comment">-- See Note [CPR for data structures]</span><span>
</span><span id="line-350"></span><span id="isDataStructure"><span class="annot"><span class="annottext">isDataStructure :: CoreBndr -&gt; Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#isDataStructure"><span class="hs-identifier hs-var hs-var">isDataStructure</span></a></span></span><span> </span><span id="local-6989586621680959107"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959107"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959106"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959106"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-351"></span><span>  </span><span class="annot"><span class="annottext">CoreBndr -&gt; Arity
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959107"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Arity -&gt; Arity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Arity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsHNF"><span class="hs-identifier hs-var">exprIsHNF</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959106"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span class="hs-comment">-- | Returns an expandable unfolding</span><span>
</span><span id="line-354"></span><span class="hs-comment">-- (See Note [exprIsExpandable] in &quot;GHC.Core.Utils&quot;) that has</span><span>
</span><span id="line-355"></span><span class="hs-comment">-- So effectively is a constructor application.</span><span>
</span><span id="line-356"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#cprDataStructureUnfolding_maybe"><span class="hs-identifier hs-type">cprDataStructureUnfolding_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-357"></span><span id="cprDataStructureUnfolding_maybe"><span class="annot"><span class="annottext">cprDataStructureUnfolding_maybe :: CoreBndr -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.Opt.CprAnal.html#cprDataStructureUnfolding_maybe"><span class="hs-identifier hs-var hs-var">cprDataStructureUnfolding_maybe</span></a></span></span><span> </span><span id="local-6989586621680959105"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959105"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-358"></span><span>  </span><span class="hs-comment">-- There are only FinalPhase Simplifier runs after CPR analysis</span><span>
</span><span id="line-359"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Maybe ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#activeInFinalPhase"><span class="hs-identifier hs-var">activeInFinalPhase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Activation
</span><a href="GHC.Types.Id.html#idInlineActivation"><span class="hs-identifier hs-var">idInlineActivation</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959105"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>  </span><span id="local-6989586621680959102"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959102"><span class="hs-identifier hs-var">unf</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Maybe (Expr CoreBndr)
</span><a href="GHC.Core.html#expandUnfolding_maybe"><span class="hs-identifier hs-var">expandUnfolding_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959105"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Maybe ()
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Expr CoreBndr -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#isDataStructure"><span class="hs-identifier hs-var">isDataStructure</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959105"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959102"><span class="hs-identifier hs-var">unf</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>  </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Maybe (Expr CoreBndr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959102"><span class="hs-identifier hs-var">unf</span></a></span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span class="hs-comment">{- Note [Arity trimming for CPR signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Although it doesn't affect correctness of the analysis per se, we have to trim
CPR signatures to idArity. Here's what might happen if we don't:

  f x = if expensive
          then \y. Box y
          else \z. Box z
  g a b = f a b

The two lambdas will have a CPR type of @1m@ (so construct a product after
applied to one argument). Thus, @f@ will have a CPR signature of @2m@
(constructs a product after applied to two arguments).
But WW will never eta-expand @f@! In this case that would amount to possibly
duplicating @expensive@ work.

(Side note: Even if @f@'s 'idArity' happened to be 2, it would not do so, see
Note [Don't eta expand in w/w].)

So @f@ will not be worker/wrappered. But @g@ also inherited its CPR signature
from @f@'s, so it *will* be WW'd:

  f x = if expensive
          then \y. Box y
          else \z. Box z
  $wg a b = case f a b of Box x -&gt; x
  g a b = Box ($wg a b)

And the case in @g@ can never cancel away, thus we introduced extra reboxing.
Hence we always trim the CPR signature of a binding to idArity.
-}</span><span>
</span><span id="line-395"></span><span>
</span><span id="line-396"></span><span class="hs-keyword">data</span><span> </span><span id="AnalEnv"><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-var">AnalEnv</span></a></span></span><span>
</span><span id="line-397"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="AE"><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AE"><span class="hs-identifier hs-var">AE</span></a></span></span><span>
</span><span id="line-398"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="ae_sigs"><span class="annot"><span class="annottext">AnalEnv -&gt; SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var hs-var">ae_sigs</span></a></span></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#SigEnv"><span class="hs-identifier hs-type">SigEnv</span></a></span><span>
</span><span id="line-399"></span><span>  </span><span class="hs-comment">-- ^ Current approximation of signatures for local ids</span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="ae_virgin"><span class="annot"><span class="annottext">AnalEnv -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var hs-var">ae_virgin</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-401"></span><span>  </span><span class="hs-comment">-- ^ True only on every first iteration in a fixed-point</span><span>
</span><span id="line-402"></span><span>  </span><span class="hs-comment">-- iteration. See Note [Initialising strictness] in &quot;GHC.Core.Opt.DmdAnal&quot;</span><span>
</span><span id="line-403"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="ae_fam_envs"><span class="annot"><span class="annottext">AnalEnv -&gt; FamInstEnvs
</span><a href="GHC.Core.Opt.CprAnal.html#ae_fam_envs"><span class="hs-identifier hs-var hs-var">ae_fam_envs</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span>
</span><span id="line-404"></span><span>  </span><span class="hs-comment">-- ^ Needed when expanding type families and synonyms of product types.</span><span>
</span><span id="line-405"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-406"></span><span>
</span><span id="line-407"></span><span class="hs-keyword">type</span><span> </span><span id="SigEnv"><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#SigEnv"><span class="hs-identifier hs-var">SigEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#VarEnv"><span class="hs-identifier hs-type">VarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#CprSig"><span class="hs-identifier hs-type">CprSig</span></a></span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680959095"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-410"></span><span>  </span><span id="local-6989586621680959089"><span class="annot"><span class="annottext">ppr :: AnalEnv -&gt; SDoc
</span><a href="#local-6989586621680959089"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_sigs :: AnalEnv -&gt; SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var">ae_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680959088"><span class="annot"><span class="annottext">SigEnv
</span><a href="#local-6989586621680959088"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_virgin :: AnalEnv -&gt; Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var">ae_virgin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680959087"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959087"><span class="hs-identifier hs-var">virgin</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-411"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;AE&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#braces"><span class="hs-identifier hs-var">braces</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span>
</span><span id="line-412"></span><span>         </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ae_virgin =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959087"><span class="hs-identifier hs-var">virgin</span></a></span><span>
</span><span id="line-413"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ae_sigs =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SigEnv -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SigEnv
</span><a href="#local-6989586621680959088"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-414"></span><span>
</span><span id="line-415"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#emptyAnalEnv"><span class="hs-identifier hs-type">emptyAnalEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-416"></span><span id="emptyAnalEnv"><span class="annot"><span class="annottext">emptyAnalEnv :: FamInstEnvs -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#emptyAnalEnv"><span class="hs-identifier hs-var hs-var">emptyAnalEnv</span></a></span></span><span> </span><span id="local-6989586621680959082"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621680959082"><span class="hs-identifier hs-var">fam_envs</span></a></span></span><span>
</span><span id="line-417"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AE :: SigEnv -&gt; Bool -&gt; FamInstEnvs -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span>
</span><span id="line-418"></span><span>  </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_sigs :: SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var">ae_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SigEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_virgin :: Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var">ae_virgin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-420"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_fam_envs :: FamInstEnvs
</span><a href="GHC.Core.Opt.CprAnal.html#ae_fam_envs"><span class="hs-identifier hs-var">ae_fam_envs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621680959082"><span class="hs-identifier hs-var">fam_envs</span></a></span><span>
</span><span id="line-421"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-422"></span><span>
</span><span id="line-423"></span><span class="hs-comment">-- | Extend an environment with the CPR sigs attached to the id</span><span>
</span><span id="line-424"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvList"><span class="hs-identifier hs-type">extendSigEnvList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-425"></span><span id="extendSigEnvList"><span class="annot"><span class="annottext">extendSigEnvList :: AnalEnv -&gt; [CoreBndr] -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvList"><span class="hs-identifier hs-var hs-var">extendSigEnvList</span></a></span></span><span> </span><span id="local-6989586621680959080"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959080"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959079"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959079"><span class="hs-identifier hs-var">ids</span></a></span></span><span>
</span><span id="line-426"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959080"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_sigs :: SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var">ae_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SigEnv
</span><a href="#local-6989586621680959078"><span class="hs-identifier hs-var">sigs'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-427"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-428"></span><span>    </span><span id="local-6989586621680959078"><span class="annot"><span class="annottext">sigs' :: SigEnv
</span><a href="#local-6989586621680959078"><span class="hs-identifier hs-var hs-var">sigs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SigEnv -&gt; [(CoreBndr, CprSig)] -&gt; SigEnv
forall a. VarEnv a -&gt; [(CoreBndr, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnvList"><span class="hs-identifier hs-var">extendVarEnvList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var hs-var">ae_sigs</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959080"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959076"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; CprSig
</span><a href="GHC.Types.Id.html#idCprInfo"><span class="hs-identifier hs-var">idCprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959076"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680959076"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959076"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959079"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-429"></span><span>
</span><span id="line-430"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#extendSigEnv"><span class="hs-identifier hs-type">extendSigEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#CprSig"><span class="hs-identifier hs-type">CprSig</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-431"></span><span id="extendSigEnv"><span class="annot"><span class="annottext">extendSigEnv :: AnalEnv -&gt; CoreBndr -&gt; CprSig -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnv"><span class="hs-identifier hs-var hs-var">extendSigEnv</span></a></span></span><span> </span><span id="local-6989586621680959075"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959075"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959074"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959074"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959073"><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959073"><span class="hs-identifier hs-var">sig</span></a></span></span><span>
</span><span id="line-432"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959075"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_sigs :: SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var">ae_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SigEnv -&gt; CoreBndr -&gt; CprSig -&gt; SigEnv
forall a. VarEnv a -&gt; CoreBndr -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var hs-var">ae_sigs</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959075"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959074"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621680959073"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#lookupSigEnv"><span class="hs-identifier hs-type">lookupSigEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#CprSig"><span class="hs-identifier hs-type">CprSig</span></a></span><span>
</span><span id="line-435"></span><span id="lookupSigEnv"><span class="annot"><span class="annottext">lookupSigEnv :: AnalEnv -&gt; CoreBndr -&gt; Maybe CprSig
</span><a href="GHC.Core.Opt.CprAnal.html#lookupSigEnv"><span class="hs-identifier hs-var hs-var">lookupSigEnv</span></a></span></span><span> </span><span id="local-6989586621680959071"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959071"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959070"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959070"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SigEnv -&gt; CoreBndr -&gt; Maybe CprSig
forall a. VarEnv a -&gt; CoreBndr -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; SigEnv
</span><a href="GHC.Core.Opt.CprAnal.html#ae_sigs"><span class="hs-identifier hs-var hs-var">ae_sigs</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959071"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959070"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-436"></span><span>
</span><span id="line-437"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#nonVirgin"><span class="hs-identifier hs-type">nonVirgin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-438"></span><span id="nonVirgin"><span class="annot"><span class="annottext">nonVirgin :: AnalEnv -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#nonVirgin"><span class="hs-identifier hs-var hs-var">nonVirgin</span></a></span></span><span> </span><span id="local-6989586621680959068"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959068"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959068"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_virgin :: Bool
</span><a href="GHC.Core.Opt.CprAnal.html#ae_virgin"><span class="hs-identifier hs-var">ae_virgin</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="hs-comment">-- | A version of 'extendSigEnv' for a binder of which we don't see the RHS</span><span>
</span><span id="line-441"></span><span class="hs-comment">-- needed to compute a 'CprSig' (e.g. lambdas and DataAlt field binders).</span><span>
</span><span id="line-442"></span><span class="hs-comment">-- In this case, we can still look at their demand to attach CPR signatures</span><span>
</span><span id="line-443"></span><span class="hs-comment">-- anticipating the unboxing done by worker/wrapper.</span><span>
</span><span id="line-444"></span><span class="hs-comment">-- See Note [CPR for binders that will be unboxed].</span><span>
</span><span id="line-445"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvForDemand"><span class="hs-identifier hs-type">extendSigEnvForDemand</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#Demand"><span class="hs-identifier hs-type">Demand</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-446"></span><span id="extendSigEnvForDemand"><span class="annot"><span class="annottext">extendSigEnvForDemand :: AnalEnv -&gt; CoreBndr -&gt; Demand -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvForDemand"><span class="hs-identifier hs-var hs-var">extendSigEnvForDemand</span></a></span></span><span> </span><span id="local-6989586621680959067"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959067"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959066"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959066"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span id="local-6989586621680959065"><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680959065"><span class="hs-identifier hs-var">dmd</span></a></span></span><span>
</span><span id="line-447"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959066"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Demand]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.WorkWrap.Utils.html#DataConAppContext"><span class="hs-identifier hs-type">DataConAppContext</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dcac_dc :: DataConAppContext -&gt; DataCon
</span><a href="GHC.Core.Opt.WorkWrap.Utils.html#dcac_dc"><span class="hs-identifier hs-var">dcac_dc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680959061"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959061"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-449"></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
-&gt; Bool -&gt; Type -&gt; Demand -&gt; Maybe ([Demand], DataConAppContext)
</span><a href="GHC.Core.Opt.WorkWrap.Utils.html#wantToUnbox"><span class="hs-identifier hs-var">wantToUnbox</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AnalEnv -&gt; FamInstEnvs
</span><a href="GHC.Core.Opt.CprAnal.html#ae_fam_envs"><span class="hs-identifier hs-var hs-var">ae_fam_envs</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959067"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959059"><span class="hs-identifier hs-var">has_inlineable_prag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959066"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680959065"><span class="hs-identifier hs-var">dmd</span></a></span><span>
</span><span id="line-450"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; CprSig -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnv"><span class="hs-identifier hs-var">extendSigEnv</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959067"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959066"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#CprSig"><span class="hs-identifier hs-var">CprSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#conCprType"><span class="hs-identifier hs-var">conCprType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Arity
</span><a href="GHC.Core.DataCon.html#dataConTag"><span class="hs-identifier hs-var">dataConTag</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959061"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-452"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959067"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-453"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-454"></span><span>    </span><span class="hs-comment">-- Rather than maintaining in AnalEnv whether we are in an INLINEABLE</span><span>
</span><span id="line-455"></span><span>    </span><span class="hs-comment">-- function, we just assume that we aren't. That flag is only relevant</span><span>
</span><span id="line-456"></span><span>    </span><span class="hs-comment">-- to Note [Do not unpack class dictionaries], the few unboxing</span><span>
</span><span id="line-457"></span><span>    </span><span class="hs-comment">-- opportunities on dicts it prohibits are probably irrelevant to CPR.</span><span>
</span><span id="line-458"></span><span>    </span><span id="local-6989586621680959059"><span class="annot"><span class="annottext">has_inlineable_prag :: Bool
</span><a href="#local-6989586621680959059"><span class="hs-identifier hs-var hs-var">has_inlineable_prag</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#extendEnvForDataAlt"><span class="hs-identifier hs-type">extendEnvForDataAlt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.CprAnal.html#AnalEnv"><span class="hs-identifier hs-type">AnalEnv</span></a></span><span>
</span><span id="line-461"></span><span class="hs-comment">-- See Note [CPR in a DataAlt case alternative]</span><span>
</span><span id="line-462"></span><span id="extendEnvForDataAlt"><span class="annot"><span class="annottext">extendEnvForDataAlt :: AnalEnv
-&gt; Expr CoreBndr -&gt; CoreBndr -&gt; DataCon -&gt; [CoreBndr] -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendEnvForDataAlt"><span class="hs-identifier hs-var hs-var">extendEnvForDataAlt</span></a></span></span><span> </span><span id="local-6989586621680959055"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959055"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680959054"><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959054"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680959053"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959053"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span id="local-6989586621680959052"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959052"><span class="hs-identifier hs-var">dc</span></a></span></span><span> </span><span id="local-6989586621680959051"><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959051"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span>
</span><span id="line-463"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(AnalEnv -&gt; (CoreBndr, StrictnessMark) -&gt; AnalEnv)
-&gt; AnalEnv -&gt; [(CoreBndr, StrictnessMark)] -&gt; AnalEnv
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; (CoreBndr, StrictnessMark) -&gt; AnalEnv
</span><a href="#local-6989586621680959050"><span class="hs-identifier hs-var">do_con_arg</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959049"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">[(CoreBndr, StrictnessMark)]
</span><a href="#local-6989586621680959048"><span class="hs-identifier hs-var">ids_w_strs</span></a></span><span>
</span><span id="line-464"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-465"></span><span>    </span><span id="local-6989586621680959049"><span class="annot"><span class="annottext">env' :: AnalEnv
</span><a href="#local-6989586621680959049"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; CprSig -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnv"><span class="hs-identifier hs-var">extendSigEnv</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959055"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959053"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CprType -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#CprSig"><span class="hs-identifier hs-var">CprSig</span></a></span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="#local-6989586621680959047"><span class="hs-identifier hs-var">case_bndr_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-466"></span><span>
</span><span id="line-467"></span><span>    </span><span id="local-6989586621680959048"><span class="annot"><span class="annottext">ids_w_strs :: [(CoreBndr, StrictnessMark)]
</span><a href="#local-6989586621680959048"><span class="hs-identifier hs-var hs-var">ids_w_strs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreBndr -&gt; Bool) -&gt; [CoreBndr] -&gt; [CoreBndr]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr]
</span><a href="#local-6989586621680959051"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreBndr] -&gt; [StrictnessMark] -&gt; [(CoreBndr, StrictnessMark)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [StrictnessMark]
</span><a href="GHC.Core.DataCon.html#dataConRepStrictness"><span class="hs-identifier hs-var">dataConRepStrictness</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959052"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-468"></span><span>
</span><span id="line-469"></span><span>    </span><span id="local-6989586621680959045"><span class="annot"><span class="annottext">tycon :: TyCon
</span><a href="#local-6989586621680959045"><span class="hs-identifier hs-var hs-var">tycon</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#dataConTyCon"><span class="hs-identifier hs-var">dataConTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959052"><span class="hs-identifier hs-var">dc</span></a></span><span>
</span><span id="line-470"></span><span>    </span><span id="local-6989586621680959043"><span class="annot"><span class="annottext">is_product :: Bool
</span><a href="#local-6989586621680959043"><span class="hs-identifier hs-var hs-var">is_product</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe DataCon -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Maybe DataCon
</span><a href="GHC.Core.TyCon.html#isDataProductTyCon_maybe"><span class="hs-identifier hs-var">isDataProductTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680959045"><span class="hs-identifier hs-var">tycon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>    </span><span id="local-6989586621680959041"><span class="annot"><span class="annottext">is_sum :: Bool
</span><a href="#local-6989586621680959041"><span class="hs-identifier hs-var hs-var">is_sum</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [DataCon] -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Maybe [DataCon]
</span><a href="GHC.Core.TyCon.html#isDataSumTyCon_maybe"><span class="hs-identifier hs-var">isDataSumTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680959045"><span class="hs-identifier hs-var">tycon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-472"></span><span>    </span><span id="local-6989586621680959047"><span class="annot"><span class="annottext">case_bndr_ty :: CprType
</span><a href="#local-6989586621680959047"><span class="hs-identifier hs-var hs-var">case_bndr_ty</span></a></span></span><span>
</span><span id="line-473"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959043"><span class="hs-identifier hs-var">is_product</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680959041"><span class="hs-identifier hs-var">is_sum</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Arity -&gt; CprType
</span><a href="GHC.Types.Cpr.html#conCprType"><span class="hs-identifier hs-var">conCprType</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Arity
</span><a href="GHC.Core.DataCon.html#dataConTag"><span class="hs-identifier hs-var">dataConTag</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680959052"><span class="hs-identifier hs-var">dc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>      </span><span class="hs-comment">-- Any of the constructors had existentials. This is a little too</span><span>
</span><span id="line-475"></span><span>      </span><span class="hs-comment">-- conservative (after all, we only care about the particular data con),</span><span>
</span><span id="line-476"></span><span>      </span><span class="hs-comment">-- but there is no easy way to write is_sum and this won't happen much.</span><span>
</span><span id="line-477"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprType
</span><a href="GHC.Types.Cpr.html#topCprType"><span class="hs-identifier hs-var">topCprType</span></a></span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span>    </span><span class="hs-comment">-- We could have much deeper CPR info here with Nested CPR, which could</span><span>
</span><span id="line-480"></span><span>    </span><span class="hs-comment">-- propagate available unboxed things from the scrutinee, getting rid of</span><span>
</span><span id="line-481"></span><span>    </span><span class="hs-comment">-- the is_var_scrut heuristic. See Note [CPR in a DataAlt case alternative].</span><span>
</span><span id="line-482"></span><span>    </span><span class="hs-comment">-- Giving strict binders the CPR property only makes sense for products, as</span><span>
</span><span id="line-483"></span><span>    </span><span class="hs-comment">-- the arguments in Note [CPR for binders that will be unboxed] don't apply</span><span>
</span><span id="line-484"></span><span>    </span><span class="hs-comment">-- to sums (yet); we lack WW for strict binders of sum type.</span><span>
</span><span id="line-485"></span><span>    </span><span id="local-6989586621680959050"><span class="annot"><span class="annottext">do_con_arg :: AnalEnv -&gt; (CoreBndr, StrictnessMark) -&gt; AnalEnv
</span><a href="#local-6989586621680959050"><span class="hs-identifier hs-var hs-var">do_con_arg</span></a></span></span><span> </span><span id="local-6989586621680959038"><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959038"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680959037"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959037"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680959036"><span class="annot"><span class="annottext">StrictnessMark
</span><a href="#local-6989586621680959036"><span class="hs-identifier hs-var">str</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-486"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr -&gt; Bool
forall b. Expr b -&gt; Bool
</span><a href="#local-6989586621680959035"><span class="hs-identifier hs-var">is_var</span></a></span><span> </span><span class="annot"><span class="annottext">Expr CoreBndr
</span><a href="#local-6989586621680959054"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-487"></span><span>       </span><span class="hs-comment">-- See Note [Add demands for strict constructors] in GHC.Core.Opt.WorkWrap.Utils</span><span>
</span><span id="line-488"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680959034"><span class="annot"><span class="annottext">dmd :: Demand
</span><a href="#local-6989586621680959034"><span class="hs-identifier hs-var hs-var">dmd</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (Demand -&gt; Demand) -&gt; Demand -&gt; Demand
forall a. Bool -&gt; (a -&gt; a) -&gt; a -&gt; a
</span><a href="GHC.Utils.Misc.html#applyWhen"><span class="hs-identifier hs-var">applyWhen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StrictnessMark -&gt; Bool
</span><a href="GHC.Core.DataCon.html#isMarkedStrict"><span class="hs-identifier hs-var">isMarkedStrict</span></a></span><span> </span><span class="annot"><span class="annottext">StrictnessMark
</span><a href="#local-6989586621680959036"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Demand -&gt; Demand
</span><a href="GHC.Types.Demand.html#strictifyDmd"><span class="hs-identifier hs-var">strictifyDmd</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreBndr -&gt; Demand
</span><a href="GHC.Types.Id.html#idDemandInfo"><span class="hs-identifier hs-var">idDemandInfo</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959037"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-489"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv -&gt; CoreBndr -&gt; Demand -&gt; AnalEnv
</span><a href="GHC.Core.Opt.CprAnal.html#extendSigEnvForDemand"><span class="hs-identifier hs-var">extendSigEnvForDemand</span></a></span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959038"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959037"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Demand
</span><a href="#local-6989586621680959034"><span class="hs-identifier hs-var">dmd</span></a></span><span>
</span><span id="line-490"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-491"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AnalEnv
</span><a href="#local-6989586621680959038"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-492"></span><span>
</span><span id="line-493"></span><span>    </span><span id="local-6989586621680959035"><span class="annot"><span class="annottext">is_var :: Expr b -&gt; Bool
</span><a href="#local-6989586621680959035"><span class="hs-identifier hs-var hs-var">is_var</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680959031"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680959031"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Bool
</span><a href="#local-6989586621680959035"><span class="hs-identifier hs-var">is_var</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680959031"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-494"></span><span>    </span><span class="annot"><a href="#local-6989586621680959035"><span class="hs-identifier hs-var">is_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680959030"><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959030"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBndr -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBndr
</span><a href="#local-6989586621680959030"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-495"></span><span>    </span><span class="annot"><a href="#local-6989586621680959035"><span class="hs-identifier hs-var">is_var</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><span class="hs-identifier">_</span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-496"></span><span>
</span><span id="line-497"></span><span class="hs-comment">{- Note [Safe abortion in the fixed-point iteration]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixed-point iteration may fail to terminate. But we cannot simply give up and
return the environment and code unchanged! We still need to do one additional
round, to ensure that all expressions have been traversed at least once, and any
unsound CPR annotations have been updated.

Note [CPR in a DataAlt case alternative]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In a case alternative, we want to give some of the binders the CPR property.
Specifically

 * The case binder; inside the alternative, the case binder always has
   the CPR property, meaning that a case on it will successfully cancel.
   Example:
        f True  x = case x of y { I# x' -&gt; if x' ==# 3
                                           then y
                                           else I# 8 }
        f False x = I# 3

   By giving 'y' the CPR property, we ensure that 'f' does too, so we get
        f b x = case fw b x of { r -&gt; I# r }
        fw True  x = case x of y { I# x' -&gt; if x' ==# 3 then x' else 8 }
        fw False x = 3

   Of course there is the usual risk of re-boxing: we have 'x' available
   boxed and unboxed, but we return the unboxed version for the wrapper to
   box.  If the wrapper doesn't cancel with its caller, we'll end up
   re-boxing something that we did have available in boxed form.

 * Any strict binders with product type, can use
   Note [CPR for binders that will be unboxed]
   to anticipate worker/wrappering for strictness info.
   But we can go a little further. Consider

      data T = MkT !Int Int

      f2 (MkT x y) | y&gt;0       = f2 (MkT x (y-1))
                   | otherwise = x

   For $wf2 we are going to unbox the MkT *and*, since it is strict, the
   first argument of the MkT; see Note [Add demands for strict constructors].
   But then we don't want box it up again when returning it!  We want
   'f2' to have the CPR property, so we give 'x' the CPR property.

 * It's a bit delicate because we're brittly anticipating worker/wrapper here.
   If the case above is scrutinising something other than an argument the
   original function, we really don't have the unboxed version available.  E.g
      g v = case foo v of
              MkT x y | y&gt;0       -&gt; ...
                      | otherwise -&gt; x
   Here we don't have the unboxed 'x' available.  Hence the
   is_var_scrut test when making use of the strictness annotation.
   Slightly ad-hoc, because even if the scrutinee *is* a variable it
   might not be a onre of the arguments to the original function, or a
   sub-component thereof.  But it's simple, and nothing terrible
   happens if we get it wrong.  e.g. Trac #10694.

Note [CPR for binders that will be unboxed]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a lambda-bound variable will be unboxed by worker/wrapper (so it must be
demanded strictly), then give it a CPR signature. Here's a concrete example
('f1' in test T10482a), assuming h is strict:

  f1 :: Int -&gt; Int
  f1 x = case h x of
          A -&gt; x
          B -&gt; f1 (x-1)
          C -&gt; x+1

If we notice that 'x' is used strictly, we can give it the CPR
property; and hence f1 gets the CPR property too.  It's sound (doesn't
change strictness) to give it the CPR property because by the time 'x'
is returned (case A above), it'll have been evaluated (by the wrapper
of 'h' in the example).

Moreover, if f itself is strict in x, then we'll pass x unboxed to
f1, and so the boxed version *won't* be available; in that case it's
very helpful to give 'x' the CPR property.

Note that

  * We only want to do this for something that definitely
    has product type, else we may get over-optimistic CPR results
    (e.g. from \x -&gt; x!).

  * This also (approximately) applies to DataAlt field binders;
    See Note [CPR in a DataAlt case alternative].

  * See Note [CPR examples]

Note [CPR for sum types]
~~~~~~~~~~~~~~~~~~~~~~~~
At the moment we do not do CPR for let-bindings that
   * non-top level
   * bind a sum type
Reason: I found that in some benchmarks we were losing let-no-escapes,
which messed it all up.  Example
   let j = \x. ....
   in case y of
        True  -&gt; j False
        False -&gt; j True
If we w/w this we get
   let j' = \x. ....
   in case y of
        True  -&gt; case j' False of { (# a #) -&gt; Just a }
        False -&gt; case j' True of { (# a #) -&gt; Just a }
Notice that j' is not a let-no-escape any more.

However this means in turn that the *enclosing* function
may be CPR'd (via the returned Justs).  But in the case of
sums, there may be Nothing alternatives; and that messes
up the sum-type CPR.

Conclusion: only do this for products.  It's still not
guaranteed OK for products, but sums definitely lose sometimes.

Note [CPR for thunks]
~~~~~~~~~~~~~~~~~~~~~
If the rhs is a thunk, we usually forget the CPR info, because
it is presumably shared (else it would have been inlined, and
so we'd lose sharing if w/w'd it into a function).  E.g.

        let r = case expensive of
                  (a,b) -&gt; (b,a)
        in ...

If we marked r as having the CPR property, then we'd w/w into

        let $wr = \() -&gt; case expensive of
                            (a,b) -&gt; (# b, a #)
            r = case $wr () of
                  (# b,a #) -&gt; (b,a)
        in ...

But now r is a thunk, which won't be inlined, so we are no further ahead.
But consider

        f x = let r = case expensive of (a,b) -&gt; (b,a)
              in if foo r then r else (x,x)

Does f have the CPR property?  Well, no.

However, if the strictness analyser has figured out (in a previous
iteration) that it's strict, then we DON'T need to forget the CPR info.
Instead we can retain the CPR info and do the thunk-splitting transform
(see WorkWrap.splitThunk).

This made a big difference to PrelBase.modInt, which had something like
        modInt = \ x -&gt; let r = ... -&gt; I# v in
                        ...body strict in r...
r's RHS isn't a value yet; but modInt returns r in various branches, so
if r doesn't have the CPR property then neither does modInt
Another case I found in practice (in Complex.magnitude), looks like this:
                let k = if ... then I# a else I# b
                in ... body strict in k ....
(For this example, it doesn't matter whether k is returned as part of
the overall result; but it does matter that k's RHS has the CPR property.)
Left to itself, the simplifier will make a join point thus:
                let $j k = ...body strict in k...
                if ... then $j (I# a) else $j (I# b)
With thunk-splitting, we get instead
                let $j x = let k = I#x in ...body strict in k...
                in if ... then $j a else $j b
This is much better; there's a good chance the I# won't get allocated.

But what about botCpr? Consider
    lvl = error &quot;boom&quot;
    fac -1 = lvl
    fac 0 = 1
    fac n = n * fac (n-1)
fac won't have the CPR property here when we trim every thunk! But the
assumption is that error cases are rarely entered and we are diverging anyway,
so WW doesn't hurt.

Should we also trim CPR on DataCon application bindings?
See Note [CPR for data structures]!

Note [CPR for data structures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Long static data structures (whether top-level or not) like

  xs = x1 : xs1
  xs1 = x2 : xs2
  xs2 = x3 : xs3

should not get CPR signatures (#18154), because they

  * Never get WW'd, so their CPR signature should be irrelevant after analysis
    (in fact the signature might even be harmful for that reason)
  * Would need to be inlined/expanded to see their constructed product
  * Recording CPR on them blows up interface file sizes and is redundant with
    their unfolding. In case of Nested CPR, this blow-up can be quadratic!
    Reason: the CPR info for xs1 contains the CPR info for xs; the CPR info
    for xs2 contains that for xs1. And so on.

Hence we don't analyse or annotate data structures in 'cprAnalBind'. To
implement this, the isDataStructure guard is triggered for bindings that satisfy

  (1) idArity id == 0 (otherwise it's a function)
  (2) exprIsHNF rhs   (otherwise it's a thunk, Note [CPR for thunks] applies)

But we can't just stop giving DataCon application bindings the CPR *property*,
for example

  fac 0 = I# 1#
  fac n = n * fac (n-1)

fac certainly has the CPR property and should be WW'd! But FloatOut will
transform the first clause to

  lvl = I# 1#
  fac 0 = lvl

If lvl doesn't have the CPR property, fac won't either. But lvl is a data
structure, and hence (see above) will not have a CPR signature. So instead, when
'cprAnal' meets a variable lacking a CPR signature to extrapolate into a CPR
transformer, 'cprTransform' instead tries to get its unfolding (via
'cprDataStructureUnfolding_maybe'), and analyses that instead.

In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one
for each data declaration. They should not have CPR signatures (blow up!).

There is a perhaps surprising special case: KindRep bindings satisfy
'isDataStructure' (so no CPR signature), but are marked NOINLINE at the same
time (see the noinline wrinkle in Note [Grand plan for Typeable]). So there is
no unfolding for 'cprDataStructureUnfolding_maybe' to look through and we'll
return topCprType. And that is fine! We should refrain to look through NOINLINE
data structures in general, as a constructed product could never be exposed
after WW.

It's also worth pointing out how ad-hoc this is: If we instead had

    f1 x = x:[]
    f2 x = x : f1 x
    f3 x = x : f2 x
    ...

we still give every function an every deepening CPR signature. But it's very
uncommon to find code like this, whereas the long static data structures from
the beginning of this Note are very common because of GHC's strategy of ANF'ing
data structure RHSs.

Note [CPR examples]
~~~~~~~~~~~~~~~~~~~~
Here are some examples (stranal/should_compile/T10482a) of the
usefulness of Note [CPR in a DataAlt case alternative].  The main
point: all of these functions can have the CPR property.

    ------- f1 -----------
    -- x is used strictly by h, so it'll be available
    -- unboxed before it is returned in the True branch

    f1 :: Int -&gt; Int
    f1 x = case h x x of
            True  -&gt; x
            False -&gt; f1 (x-1)

    ------- f3 -----------
    -- h is strict in x, so x will be unboxed before it
    -- is rerturned in the otherwise case.

    data T3 = MkT3 Int Int

    f1 :: T3 -&gt; Int
    f1 (MkT3 x y) | h x y     = f3 (MkT3 x (y-1))
                  | otherwise = x
-}</span><span>
</span><span id="line-766"></span></pre></body></html>